<!-- 库存汇总查询 - 综合表单页面 -->
<template>
  <div class="page-container">
    <ex_super_table_page v-bind="option" ref="SuperTablePage">
    </ex_super_table_page>
    <!-- <el-dialog :title="`[${$tt('label_stock_detail')}] ` + chooseRow.skuName + ' - ' + chooseRow.skuNameEn"
      :visible.sync="dialogVisible" width="1100px">
      <ex_super_table class="el-table-nowwarp" ref="resourceDownloadGridPanelEl"
        :url="'/wms-api/stock/StockQueryRpc/stockContainerQuery.json?skuId=' + chooseRow.skuId + '&warehouseId=' + chooseRow.warehouseId"
        :attrs="{ autoPage: true, autoLoad: true }" height="400" v-bind="tableOption">
      </ex_super_table>
      <span slot="footer" class="dialog_footer">
        <el-button @click="dialogVisible = false">{{ $tt('label_close') }}</el-button>
      </span>
    </el-dialog> -->

    <ex_super_dialog_form ref="detailDialog" v-bind="detail_dialog" noSubmit>
    </ex_super_dialog_form>

  </div>
</template>
<script>
import superTablePageFunction from '@/mixin/super-table-page-function';


export default {
  title: 'title_stock_head_query',
  mixins: [superTablePageFunction],

  components: {},
  data() {
    return {

      // dialogVisible: false,
      chooseRow: {},

      option: {
        search: {
          model: [
            { label: "label_customer", key: "customerId", type: 'common_customer_choose', },
            { label: "label_sku", key: "skuId", type: 'sku_selec_input', },
            { label: "label_quantity_type", key: "qtyType", type: 'select', enum: 'StockQtyTypeEnum' },
            // { label: "label_quantity_range", key: "qty1", type: 'input',  },
            // { label: "", key: "qty2", type: 'input',}
          ],
        },
        action: [

        ],

        table: {
          url: "/wms-api/stock/StockQueryRpc/stockHeadQuery.json",
          attrs: {},
          model: [

            {
              key: 'customerCode', label: 'label_srm_api_request_customer_code', align: 'left', 'width': 150,
              attrs: {
                formatter: (r, c, v, i) => r.customerCode + (r.customerName ? ("-" + r.customerName) : "")
              }
            },
            {
              key: 'skuOnlyCode', label: 'label_sku_only_code', align: 'left', 'min-width': 160,
              attrs: {
                formatter: (r, c, v, i) => r.skuId < 0 ? "-" : v
              }
            },

            {
              key: 'skuName', label: 'label_sku_name', align: 'left','width': 160,
              attrs: {
                formatter: (r, c, v, i) => r.skuId < 0 ? "-" : v + (r.skuNameEn ? ( '-' + r.skuNameEn ): '')
              }
            },
            // {
            //   key: 'skuNameEn', label: 'label_sku_name_en', align: 'left',
            //   attrs: {
            //     formatter: (r, c, v, i) => r.skuId < 0 ? "——" : v
            //   }
            // },
            // {
            //   key: 'onwayQty', label: '在途数量',
            // },
            {
              key: 'needPutawayQyt', label: 'label_wait_put_count', align: 'right','width': 100,
            },
            {
              key: 'allotPutawayQyt', label: 'label_Transfer_transit_stock', align: 'right','width': 100,
            },
            {
              key: 'needOutboudQty', label: 'label_wait_outbound_count', align: 'right','width': 100,
            },


            // TOC 数量字段
            {
              key: 'tcLockQty', label: 'label_toc_lock_count', align: 'right','width': 100,
            },
            {
              key: 'tcUsableQty', label: 'label_toc_usable_count', align: 'right','width': 100,
            },
            // {
            //   key: 'tcFreezeQty', label: 'label_toc_frozen_count',
            // },

            // TOB 数量字段
            {
              key: 'tbLockQty', label: 'label_tob_lock_count', align: 'right','width': 100,
            },
            {
              key: 'tbUsableQty', label: 'label_tob_usable_count', align: 'right','width': 100,
            },
            // {
            //   key: 'tbFreezeQty', label: 'label_tob_frozen_count',
            // },

            // {
            //   key: 'destroyQty', label: 'label_abnormal_stock',
            // },

            {
              key: 'totalQty', label: 'label_usable_count', align: 'right', 'width': 100, // 可用数量（良品/不良品
              attrs: {
                formatter: (r, c, v, i) => (r.goodUsableQty + r.badUsableQty) // + '/' + r.goodUsableQty + '/' + r.badUsableQty
              }
            },
            // {
            //   key: 'totalQty', label: 'label_lock_count', // （良品/不良品）
            //   attrs: {
            //     formatter: (r, c, v, i) => (r.goodLockQty + r.badLockQty)  // + '/' + r.goodLockQty + '/' + r.badLockQty
            //   }
            // },
            // {
            //   key: 'totalQty', label: 'label_frozen_count', // 冻结数量（良品/不良品）
            //   attrs: {
            //     formatter: (r, c, v, i) => (r.goodFreezeQty + r.badFreezeQty) // + '/' + r.goodFreezeQty + '/' + r.badFreezeQty
            //   }
            // },
            {
              key: 'totalQty', label: 'label_sum_stock', align: 'right','width': 100,
            },
            {
              type: 'operate', width: 160, fixed: "right", operate: [

                {
                  label: 'label_view_detail', click: (row) => {
                    this.chooseRow = row
                    this.$refs.detailDialog.showNew({
                      title: this.$formatNameCode(this.$tt('label_stock_detail'), `${this.chooseRow.skuName} - ${this.chooseRow.skuNameEn}`),
                      data: {
                        rows: [],
                        ...row
                      },
                      onlySetData: true,
                    })
                    this.$nextTick(() => {
                      this.$refs.detailDialog.getRef("rows").reload()
                    })
                  }
                }

              ],
            }
          ],

        }
        ,

      },
      detail_dialog: {
        customClass: 'dialog_big',
        form: {
          default: {},
          model: [
            {
              key: 'rows', label: 'label_grid_mouth', formType: "itemTable",
              attrs: {
                url: "/wms-api/stock/StockQueryRpc/stockContainerQuery.json",
                autoPage: true, autoLoad: false, height: 400,
                urlParams: () => ({
                  skuId: this.chooseRow.skuId,
                  warehouseId: this.chooseRow.warehouseId,
                }),
              },
              model: [
                { key: 'locationCode', label: 'label_warehouse_location_code', 'min-width': 140, 'show-overflow-tooltip': true, },
                { key: 'subContainerCode', label: 'label_container_code', 'min-width': 140, 'show-overflow-tooltip': true, },
                {
                  key: 'bizType', label: 'label_business_type', 'width': 120, 'show-overflow-tooltip': true,
                  formatter: (r, c, v, i) => this.$enumShow(v, "BizTypeEnum")
                },
                { key: 'stockKind', label: 'label_stock_quality', 'width': 120, 'show-overflow-tooltip': true, formatter: (r, c, v) => this.$enumShow(v, 'StockKindEnum') },
                { key: 'freezeQty', label: 'label_frozen_count', 'width': 120, 'show-overflow-tooltip': true, },
                { key: 'lockQty', label: 'label_lock_count', 'width': 120, 'show-overflow-tooltip': true, },
                { key: 'usableQty', label: 'label_usable_count', 'width': 120, 'show-overflow-tooltip': true, },
                { key: 'totalQty', label: 'label_container_inner_sum_count', 'width': 120, 'show-overflow-tooltip': true, },
                { key: 'putawayOrderNo', label: 'label_putaway_code', 'width': 120, 'show-overflow-tooltip': true, },
                { key: 'putawayTime', label: 'label_putaway_time', 'width': 130, 'show-overflow-tooltip': true, formatter: (r, c, v) => this.$dateFormat(v) },
              ],
            },

          ],

        }
      },
      tableOption: {
        model: [
          { key: 'locationCode', label: 'label_warehouse_location_code', 'min-width': 140, 'show-overflow-tooltip': true, },
          { key: 'subContainerCode', label: 'label_container_code', 'min-width': 140, 'show-overflow-tooltip': true, },

          { key: 'stockKind', label: 'label_stock_quality', 'width': 120, 'show-overflow-tooltip': true, formatter: (r, c, v) => this.$enumShow(v, 'StockKindEnum') },

          { key: 'freezeQty', label: 'label_frozen_count', 'width': 120, 'show-overflow-tooltip': true, },

          { key: 'lockQty', label: 'label_lock_count', 'width': 120, 'show-overflow-tooltip': true, },
          { key: 'usableQty', label: 'label_usable_count', 'width': 120, 'show-overflow-tooltip': true, },

          { key: 'totalQty', label: 'label_container_inner_sum_count', 'width': 120, 'show-overflow-tooltip': true, },

          { key: 'putawayTime', label: 'label_putaway_time', 'width': 130, 'show-overflow-tooltip': true, formatter: (r, c, v) => this.$dateFormat(v) },



        ]
      },

    };
  },
  methods: {
  }
};

</script>
<style></style>
